package com.happystudy.serviceImpl;

import com.happpystudy.model.course.CourseKey;
import com.happpystudy.model.course.CourseScheduleKey;
import com.happpystudy.service.CourseScheduleKeyService;
import com.happystudy.mapper.CourseScheduleMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CourseScheduleKeyServiceImpl implements CourseScheduleKeyService {

    @Resource
    CourseScheduleMapper courseScheduleMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int insertSelectiveByList(List<CourseScheduleKey> list) {
        Integer result = 0;
        for (CourseScheduleKey courseScheduleKey:list){
            result += insertSelective(courseScheduleKey);
        }
        return result;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int insertSelective(CourseScheduleKey courseScheduleKey) {
        Integer result = 0;
        result = courseScheduleMapper.insertSelective(courseScheduleKey);
        return result;
    }
    @Override
    public List<CourseScheduleKey> queryAllScheduleByCourseKey(CourseKey courseKey){
        return courseScheduleMapper.selectByCourseKey(courseKey);
    }
}
